package com.android.tiango.baba.chosephoto;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.scsd.tiango.R;
import com.android.tiango.baba.entity.PicModel;

public class ListPicAdapter extends BaseAdapter {
	private List<PicModel> list;
	private Context context;

	public ListPicAdapter(Context context, List<PicModel> list) {
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public PicModel getItem(int arg0) {
		return list.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		HolderView holderView;
		if (convertView == null) {
			holderView = new HolderView();
			convertView = LayoutInflater.from(context).inflate(R.layout.item_piclist, null);
			convertView.setTag(holderView);
		} else {
			holderView = (HolderView) convertView.getTag();
		}
		holderView.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
		holderView.tv_num = (TextView) convertView.findViewById(R.id.tv_num);
		PicModel model = (PicModel) getItem(position);
		if (null != model) {
			holderView.tv_name.setText(model.getPicPath());
			// holderView.tv_num.setText("(" + model.getPicNum() + ")");
		}
		return convertView;
	}

	class HolderView {
		public TextView tv_name, tv_num;
	}
}
